{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import json\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [],
   "source": [
    "KEY = 'c964a10a960e49f69af57be4aaea06dc'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [],
   "source": [
    "BASE_URL = 'https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [],
   "source": [
    "HEADERS = {\n",
    "    # Request headers\n",
    "    'Content-Type': 'application/json',\n",
    "    'Ocp-Apim-Subscription-Key': '{}'.format(KEY), #''  \n",
    "}\n",
    "\n",
    "img_url = 'http://5b0988e595225.cdn.sohucs.com/images/20190422/2b6381a9cedc42da8740de318840309a.jpeg'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {\n",
    "    'url': '{}'.format(img_url),\n",
    "}\n",
    "payload = {\n",
    "    'returnFaceId': 'true',\n",
    "    'returnFaceLandmarks': 'flase',\n",
    "    'returnFaceAttributes': '{}'.format('age,gender,glasses'), \n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [],
   "source": [
    "r = requests.post(BASE_URL,data=json.dumps(data),params = payload,headers=HEADERS)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "200"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.status_code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'bytes'>\n"
     ]
    }
   ],
   "source": [
    "print(type(r.content))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'faceId': '280ade5d-23d0-43a3-916c-fc1165ddc3dd',\n",
       "  'faceRectangle': {'top': 127, 'left': 342, 'width': 117, 'height': 117},\n",
       "  'faceAttributes': {'gender': 'male', 'age': 40.0, 'glasses': 'NoGlasses'}},\n",
       " {'faceId': '8d247d73-428e-4520-bdd9-02c53698e3cc',\n",
       "  'faceRectangle': {'top': 106, 'left': 166, 'width': 116, 'height': 116},\n",
       "  'faceAttributes': {'gender': 'male', 'age': 57.0, 'glasses': 'NoGlasses'}},\n",
       " {'faceId': '3fe035f5-5dbb-424d-96d4-c5800a16a406',\n",
       "  'faceRectangle': {'top': 127, 'left': 43, 'width': 110, 'height': 110},\n",
       "  'faceAttributes': {'gender': 'male', 'age': 42.0, 'glasses': 'NoGlasses'}},\n",
       " {'faceId': 'd3585653-b02f-406d-90ab-edcb6e3488b5',\n",
       "  'faceRectangle': {'top': 427, 'left': 33, 'width': 92, 'height': 92},\n",
       "  'faceAttributes': {'gender': 'male', 'age': 36.0, 'glasses': 'NoGlasses'}},\n",
       " {'faceId': '765f9820-f749-4389-9273-3fd95f6129f8',\n",
       "  'faceRectangle': {'top': 410, 'left': 224, 'width': 89, 'height': 89},\n",
       "  'faceAttributes': {'gender': 'male', 'age': 43.0, 'glasses': 'NoGlasses'}},\n",
       " {'faceId': '2f4f9534-9f47-4dbd-8896-be29268f6145',\n",
       "  'faceRectangle': {'top': 362, 'left': 390, 'width': 80, 'height': 80},\n",
       "  'faceAttributes': {'gender': 'male', 'age': 41.0, 'glasses': 'NoGlasses'}}]"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>faceId</th>\n",
       "      <th>faceRectangle.top</th>\n",
       "      <th>faceRectangle.left</th>\n",
       "      <th>faceRectangle.width</th>\n",
       "      <th>faceRectangle.height</th>\n",
       "      <th>faceAttributes.gender</th>\n",
       "      <th>faceAttributes.age</th>\n",
       "      <th>faceAttributes.glasses</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>280ade5d-23d0-43a3-916c-fc1165ddc3dd</td>\n",
       "      <td>127</td>\n",
       "      <td>342</td>\n",
       "      <td>117</td>\n",
       "      <td>117</td>\n",
       "      <td>male</td>\n",
       "      <td>40.0</td>\n",
       "      <td>NoGlasses</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>8d247d73-428e-4520-bdd9-02c53698e3cc</td>\n",
       "      <td>106</td>\n",
       "      <td>166</td>\n",
       "      <td>116</td>\n",
       "      <td>116</td>\n",
       "      <td>male</td>\n",
       "      <td>57.0</td>\n",
       "      <td>NoGlasses</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3fe035f5-5dbb-424d-96d4-c5800a16a406</td>\n",
       "      <td>127</td>\n",
       "      <td>43</td>\n",
       "      <td>110</td>\n",
       "      <td>110</td>\n",
       "      <td>male</td>\n",
       "      <td>42.0</td>\n",
       "      <td>NoGlasses</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>d3585653-b02f-406d-90ab-edcb6e3488b5</td>\n",
       "      <td>427</td>\n",
       "      <td>33</td>\n",
       "      <td>92</td>\n",
       "      <td>92</td>\n",
       "      <td>male</td>\n",
       "      <td>36.0</td>\n",
       "      <td>NoGlasses</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>765f9820-f749-4389-9273-3fd95f6129f8</td>\n",
       "      <td>410</td>\n",
       "      <td>224</td>\n",
       "      <td>89</td>\n",
       "      <td>89</td>\n",
       "      <td>male</td>\n",
       "      <td>43.0</td>\n",
       "      <td>NoGlasses</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2f4f9534-9f47-4dbd-8896-be29268f6145</td>\n",
       "      <td>362</td>\n",
       "      <td>390</td>\n",
       "      <td>80</td>\n",
       "      <td>80</td>\n",
       "      <td>male</td>\n",
       "      <td>41.0</td>\n",
       "      <td>NoGlasses</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                 faceId  faceRectangle.top  \\\n",
       "0  280ade5d-23d0-43a3-916c-fc1165ddc3dd                127   \n",
       "1  8d247d73-428e-4520-bdd9-02c53698e3cc                106   \n",
       "2  3fe035f5-5dbb-424d-96d4-c5800a16a406                127   \n",
       "3  d3585653-b02f-406d-90ab-edcb6e3488b5                427   \n",
       "4  765f9820-f749-4389-9273-3fd95f6129f8                410   \n",
       "5  2f4f9534-9f47-4dbd-8896-be29268f6145                362   \n",
       "\n",
       "   faceRectangle.left  faceRectangle.width  faceRectangle.height  \\\n",
       "0                 342                  117                   117   \n",
       "1                 166                  116                   116   \n",
       "2                  43                  110                   110   \n",
       "3                  33                   92                    92   \n",
       "4                 224                   89                    89   \n",
       "5                 390                   80                    80   \n",
       "\n",
       "  faceAttributes.gender  faceAttributes.age faceAttributes.glasses  \n",
       "0                  male                40.0              NoGlasses  \n",
       "1                  male                57.0              NoGlasses  \n",
       "2                  male                42.0              NoGlasses  \n",
       "3                  male                36.0              NoGlasses  \n",
       "4                  male                43.0              NoGlasses  \n",
       "5                  male                41.0              NoGlasses  "
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 此处老师的代码出现失误\n",
    "# 原代码df = pd.json_normalize(r)\n",
    "\n",
    "from pandas.io.json import json_normalize\n",
    "json_normalize(r.json())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# face++"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import urllib.request\n",
    "# import urllib.error\n",
    "# import time\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "BASE_URL = 'https://api-cn.faceplusplus.com/facepp/v3/detect'\n",
    "api_key = \"EDwY07cypWQad39XZPwwlhkiVBWEIH2G\" # \"填上你的KEY\"\n",
    "api_secret = \"YUxYrOjrQk938x2pen35EcuclOcWsvXO\" # \"填上你的SECRET\"\n",
    "img_url = \"http://5b0988e595225.cdn.sohucs.com/images/20190422/2b6381a9cedc42da8740de318840309a.jpeg\" # r\"本地图片的路径\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "metadata": {},
   "outputs": [],
   "source": [
    "headers = {\n",
    "    'Content-Type': 'application/json',\n",
    "}\n",
    "\n",
    "\n",
    "payload = {\n",
    "    \"image_url\":img_url,\n",
    "    'api_key': api_key,\n",
    "    'api_secret': api_secret,\n",
    "    'return_attributes':'gender,age,smiling,emotion', \n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "200"
      ]
     },
     "execution_count": 134,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r = requests.post(BASE_URL, params=payload, headers=headers)\n",
    "r.status_code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'{\"request_id\":\"1585886059,da9bc990-d46b-4561-9d7b-5199e4d81cdb\",\"time_used\":1291,\"faces\":[{\"face_token\":\"4948ad31674392b6a41921e96c317638\",\"face_rectangle\":{\"top\":114,\"left\":182,\"width\":111,\"height\":111},\"attributes\":{\"gender\":{\"value\":\"Male\"},\"age\":{\"value\":51},\"smile\":{\"value\":1.515,\"threshold\":50.000},\"emotion\":{\"anger\":1.655,\"disgust\":40.726,\"fear\":0.120,\"happiness\":1.398,\"neutral\":55.824,\"sadness\":0.076,\"surprise\":0.201}}},{\"face_token\":\"924111bb3825be84de90bac91ffe72de\",\"face_rectangle\":{\"top\":137,\"left\":357,\"width\":110,\"height\":110},\"attributes\":{\"gender\":{\"value\":\"Male\"},\"age\":{\"value\":33},\"smile\":{\"value\":9.484,\"threshold\":50.000},\"emotion\":{\"anger\":3.668,\"disgust\":14.784,\"fear\":6.558,\"happiness\":0.029,\"neutral\":69.337,\"sadness\":5.595,\"surprise\":0.029}}},{\"face_token\":\"cc8c863e0a972c6debc57987b26304ba\",\"face_rectangle\":{\"top\":135,\"left\":28,\"width\":109,\"height\":109},\"attributes\":{\"gender\":{\"value\":\"Male\"},\"age\":{\"value\":52},\"smile\":{\"value\":0.117,\"threshold\":50.000},\"emotion\":{\"anger\":3.497,\"disgust\":0.037,\"fear\":5.541,\"happiness\":0.037,\"neutral\":51.520,\"sadness\":39.195,\"surprise\":0.172}}},{\"face_token\":\"48fd5d422ea33a8141ca76d8adea3498\",\"face_rectangle\":{\"top\":413,\"left\":208,\"width\":89,\"height\":89},\"attributes\":{\"gender\":{\"value\":\"Male\"},\"age\":{\"value\":28},\"smile\":{\"value\":5.590,\"threshold\":50.000},\"emotion\":{\"anger\":0.004,\"disgust\":0.001,\"fear\":0.000,\"happiness\":0.000,\"neutral\":99.995,\"sadness\":0.000,\"surprise\":0.000}}},{\"face_token\":\"65a336536b7bad06e8d75a1e0dd75884\",\"face_rectangle\":{\"top\":432,\"left\":22,\"width\":89,\"height\":89},\"attributes\":{\"gender\":{\"value\":\"Male\"},\"age\":{\"value\":33},\"smile\":{\"value\":0.064,\"threshold\":50.000},\"emotion\":{\"anger\":0.175,\"disgust\":1.531,\"fear\":0.014,\"happiness\":0.010,\"neutral\":98.030,\"sadness\":0.230,\"surprise\":0.010}}},{\"face_token\":\"31afaeccef7bb853f4428db071861a10\",\"face_rectangle\":{\"top\":365,\"left\":394,\"width\":83,\"height\":83}}],\"image_id\":\"Tvv7j4RcEiDmcoKIqLzMaQ==\",\"face_num\":6}\\n'"
      ]
     },
     "execution_count": 135,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1585886059,da9bc990-d46b-4561-9d7b-5199e4d81cdb',\n",
       " 'time_used': 1291,\n",
       " 'faces': [{'face_token': '4948ad31674392b6a41921e96c317638',\n",
       "   'face_rectangle': {'top': 114, 'left': 182, 'width': 111, 'height': 111},\n",
       "   'attributes': {'gender': {'value': 'Male'},\n",
       "    'age': {'value': 51},\n",
       "    'smile': {'value': 1.515, 'threshold': 50.0},\n",
       "    'emotion': {'anger': 1.655,\n",
       "     'disgust': 40.726,\n",
       "     'fear': 0.12,\n",
       "     'happiness': 1.398,\n",
       "     'neutral': 55.824,\n",
       "     'sadness': 0.076,\n",
       "     'surprise': 0.201}}},\n",
       "  {'face_token': '924111bb3825be84de90bac91ffe72de',\n",
       "   'face_rectangle': {'top': 137, 'left': 357, 'width': 110, 'height': 110},\n",
       "   'attributes': {'gender': {'value': 'Male'},\n",
       "    'age': {'value': 33},\n",
       "    'smile': {'value': 9.484, 'threshold': 50.0},\n",
       "    'emotion': {'anger': 3.668,\n",
       "     'disgust': 14.784,\n",
       "     'fear': 6.558,\n",
       "     'happiness': 0.029,\n",
       "     'neutral': 69.337,\n",
       "     'sadness': 5.595,\n",
       "     'surprise': 0.029}}},\n",
       "  {'face_token': 'cc8c863e0a972c6debc57987b26304ba',\n",
       "   'face_rectangle': {'top': 135, 'left': 28, 'width': 109, 'height': 109},\n",
       "   'attributes': {'gender': {'value': 'Male'},\n",
       "    'age': {'value': 52},\n",
       "    'smile': {'value': 0.117, 'threshold': 50.0},\n",
       "    'emotion': {'anger': 3.497,\n",
       "     'disgust': 0.037,\n",
       "     'fear': 5.541,\n",
       "     'happiness': 0.037,\n",
       "     'neutral': 51.52,\n",
       "     'sadness': 39.195,\n",
       "     'surprise': 0.172}}},\n",
       "  {'face_token': '48fd5d422ea33a8141ca76d8adea3498',\n",
       "   'face_rectangle': {'top': 413, 'left': 208, 'width': 89, 'height': 89},\n",
       "   'attributes': {'gender': {'value': 'Male'},\n",
       "    'age': {'value': 28},\n",
       "    'smile': {'value': 5.59, 'threshold': 50.0},\n",
       "    'emotion': {'anger': 0.004,\n",
       "     'disgust': 0.001,\n",
       "     'fear': 0.0,\n",
       "     'happiness': 0.0,\n",
       "     'neutral': 99.995,\n",
       "     'sadness': 0.0,\n",
       "     'surprise': 0.0}}},\n",
       "  {'face_token': '65a336536b7bad06e8d75a1e0dd75884',\n",
       "   'face_rectangle': {'top': 432, 'left': 22, 'width': 89, 'height': 89},\n",
       "   'attributes': {'gender': {'value': 'Male'},\n",
       "    'age': {'value': 33},\n",
       "    'smile': {'value': 0.064, 'threshold': 50.0},\n",
       "    'emotion': {'anger': 0.175,\n",
       "     'disgust': 1.531,\n",
       "     'fear': 0.014,\n",
       "     'happiness': 0.01,\n",
       "     'neutral': 98.03,\n",
       "     'sadness': 0.23,\n",
       "     'surprise': 0.01}}},\n",
       "  {'face_token': '31afaeccef7bb853f4428db071861a10',\n",
       "   'face_rectangle': {'top': 365, 'left': 394, 'width': 83, 'height': 83}}],\n",
       " 'image_id': 'Tvv7j4RcEiDmcoKIqLzMaQ==',\n",
       " 'face_num': 6}"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results = r.json() # \n",
    "results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>face_token</th>\n",
       "      <th>face_rectangle.top</th>\n",
       "      <th>face_rectangle.left</th>\n",
       "      <th>face_rectangle.width</th>\n",
       "      <th>face_rectangle.height</th>\n",
       "      <th>attributes.gender.value</th>\n",
       "      <th>attributes.age.value</th>\n",
       "      <th>attributes.smile.value</th>\n",
       "      <th>attributes.smile.threshold</th>\n",
       "      <th>attributes.emotion.anger</th>\n",
       "      <th>attributes.emotion.disgust</th>\n",
       "      <th>attributes.emotion.fear</th>\n",
       "      <th>attributes.emotion.happiness</th>\n",
       "      <th>attributes.emotion.neutral</th>\n",
       "      <th>attributes.emotion.sadness</th>\n",
       "      <th>attributes.emotion.surprise</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4948ad31674392b6a41921e96c317638</td>\n",
       "      <td>114</td>\n",
       "      <td>182</td>\n",
       "      <td>111</td>\n",
       "      <td>111</td>\n",
       "      <td>Male</td>\n",
       "      <td>51.0</td>\n",
       "      <td>1.515</td>\n",
       "      <td>50.0</td>\n",
       "      <td>1.655</td>\n",
       "      <td>40.726</td>\n",
       "      <td>0.120</td>\n",
       "      <td>1.398</td>\n",
       "      <td>55.824</td>\n",
       "      <td>0.076</td>\n",
       "      <td>0.201</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>924111bb3825be84de90bac91ffe72de</td>\n",
       "      <td>137</td>\n",
       "      <td>357</td>\n",
       "      <td>110</td>\n",
       "      <td>110</td>\n",
       "      <td>Male</td>\n",
       "      <td>33.0</td>\n",
       "      <td>9.484</td>\n",
       "      <td>50.0</td>\n",
       "      <td>3.668</td>\n",
       "      <td>14.784</td>\n",
       "      <td>6.558</td>\n",
       "      <td>0.029</td>\n",
       "      <td>69.337</td>\n",
       "      <td>5.595</td>\n",
       "      <td>0.029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>cc8c863e0a972c6debc57987b26304ba</td>\n",
       "      <td>135</td>\n",
       "      <td>28</td>\n",
       "      <td>109</td>\n",
       "      <td>109</td>\n",
       "      <td>Male</td>\n",
       "      <td>52.0</td>\n",
       "      <td>0.117</td>\n",
       "      <td>50.0</td>\n",
       "      <td>3.497</td>\n",
       "      <td>0.037</td>\n",
       "      <td>5.541</td>\n",
       "      <td>0.037</td>\n",
       "      <td>51.520</td>\n",
       "      <td>39.195</td>\n",
       "      <td>0.172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>48fd5d422ea33a8141ca76d8adea3498</td>\n",
       "      <td>413</td>\n",
       "      <td>208</td>\n",
       "      <td>89</td>\n",
       "      <td>89</td>\n",
       "      <td>Male</td>\n",
       "      <td>28.0</td>\n",
       "      <td>5.590</td>\n",
       "      <td>50.0</td>\n",
       "      <td>0.004</td>\n",
       "      <td>0.001</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>99.995</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>65a336536b7bad06e8d75a1e0dd75884</td>\n",
       "      <td>432</td>\n",
       "      <td>22</td>\n",
       "      <td>89</td>\n",
       "      <td>89</td>\n",
       "      <td>Male</td>\n",
       "      <td>33.0</td>\n",
       "      <td>0.064</td>\n",
       "      <td>50.0</td>\n",
       "      <td>0.175</td>\n",
       "      <td>1.531</td>\n",
       "      <td>0.014</td>\n",
       "      <td>0.010</td>\n",
       "      <td>98.030</td>\n",
       "      <td>0.230</td>\n",
       "      <td>0.010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>31afaeccef7bb853f4428db071861a10</td>\n",
       "      <td>365</td>\n",
       "      <td>394</td>\n",
       "      <td>83</td>\n",
       "      <td>83</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         face_token  face_rectangle.top  face_rectangle.left  \\\n",
       "0  4948ad31674392b6a41921e96c317638                 114                  182   \n",
       "1  924111bb3825be84de90bac91ffe72de                 137                  357   \n",
       "2  cc8c863e0a972c6debc57987b26304ba                 135                   28   \n",
       "3  48fd5d422ea33a8141ca76d8adea3498                 413                  208   \n",
       "4  65a336536b7bad06e8d75a1e0dd75884                 432                   22   \n",
       "5  31afaeccef7bb853f4428db071861a10                 365                  394   \n",
       "\n",
       "   face_rectangle.width  face_rectangle.height attributes.gender.value  \\\n",
       "0                   111                    111                    Male   \n",
       "1                   110                    110                    Male   \n",
       "2                   109                    109                    Male   \n",
       "3                    89                     89                    Male   \n",
       "4                    89                     89                    Male   \n",
       "5                    83                     83                     NaN   \n",
       "\n",
       "   attributes.age.value  attributes.smile.value  attributes.smile.threshold  \\\n",
       "0                  51.0                   1.515                        50.0   \n",
       "1                  33.0                   9.484                        50.0   \n",
       "2                  52.0                   0.117                        50.0   \n",
       "3                  28.0                   5.590                        50.0   \n",
       "4                  33.0                   0.064                        50.0   \n",
       "5                   NaN                     NaN                         NaN   \n",
       "\n",
       "   attributes.emotion.anger  attributes.emotion.disgust  \\\n",
       "0                     1.655                      40.726   \n",
       "1                     3.668                      14.784   \n",
       "2                     3.497                       0.037   \n",
       "3                     0.004                       0.001   \n",
       "4                     0.175                       1.531   \n",
       "5                       NaN                         NaN   \n",
       "\n",
       "   attributes.emotion.fear  attributes.emotion.happiness  \\\n",
       "0                    0.120                         1.398   \n",
       "1                    6.558                         0.029   \n",
       "2                    5.541                         0.037   \n",
       "3                    0.000                         0.000   \n",
       "4                    0.014                         0.010   \n",
       "5                      NaN                           NaN   \n",
       "\n",
       "   attributes.emotion.neutral  attributes.emotion.sadness  \\\n",
       "0                      55.824                       0.076   \n",
       "1                      69.337                       5.595   \n",
       "2                      51.520                      39.195   \n",
       "3                      99.995                       0.000   \n",
       "4                      98.030                       0.230   \n",
       "5                         NaN                         NaN   \n",
       "\n",
       "   attributes.emotion.surprise  \n",
       "0                        0.201  \n",
       "1                        0.029  \n",
       "2                        0.172  \n",
       "3                        0.000  \n",
       "4                        0.010  \n",
       "5                          NaN  "
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pandas.io.json import json_normalize\n",
    "df = json_normalize(results,record_path='faces')\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 腾讯云"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'apiuitl'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m        Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-38-6f5baed2aade>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'../AIPlat'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mapiuitl\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'apiuitl'"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "sys.path.append('../AIPlat')\n",
    "import apiuitl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
